package com.three.controller;

import com.baor.baseUtil.R;
import com.three.domain.Students;
import com.three.service.PrestudentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class PrestudentsController {

    @Autowired
    private PrestudentsService prestudentsService;
//    获取预招生列表
    @RequestMapping(value = "/prestudentsList")
    public R getPrestudentsList(@RequestBody Map<String, Object> map) {
        int pageIndex = (int) map.get("pageIndex");
        int pageSize = (int) map.get("pageSize");
        Integer xiaoshou_id = (Integer) map.get("xiaoshou_id");
        return prestudentsService.prestudentsList(pageIndex, pageSize,xiaoshou_id);
    }
//    添加预招生
    @RequestMapping(value = "/addpre")
    public R addpre(@RequestBody Students students) {

        return prestudentsService.addpre(students);
    }
    // 修改更新预招生信息
    @RequestMapping("/updateprestu")
    public R updatepreStudent(@RequestBody Students student) {

        return prestudentsService.updatepreStudent(student);
    }

    // 软删除预招生
    @RequestMapping("/deleteprestu")
    public String softDeletepreStudent(@RequestBody Map<String, Integer> requestBody) {
        int student_id = requestBody.get("student_id");
        prestudentsService.softDeletepreStudent(student_id);
        return "预招生已被软删除";
    }

    @RequestMapping("/searchprestu")
    public R searchStudents(@RequestBody Map<String, Object> map) {
        int pageIndex = (int) map.get("pageIndex");
        int pageSize = (int) map.get("pageSize");
        String name = (String) map.get("keyword");
        Integer xiaoshou_id = (Integer) map.get("xiaoshou_id");
        return prestudentsService.findpreStudentsByName(pageIndex,pageSize,name,xiaoshou_id);
    }

    @RequestMapping("/updateStatus")
    public R updateStatus() {
        return prestudentsService.updateStatus();
    }

}
